package views;

import java.awt.FlowLayout;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JProgressBar;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.InternalFrameListener;

@SuppressWarnings("serial")
public class ImportarGUI extends JInternalFrame {

	public JButton btImportar;
	public JButton btAnalisar;
	public JTextField tfArquivo;
	public JTextArea taAnalise;
	public JProgressBar pbProgressBar;

	public ImportarGUI() {
		super("Importar AFD", false, true, false, true);
		setLayout(new FlowLayout());
		configComponents();
		add(tfArquivo);
		add(btImportar);
		add(btAnalisar);
		add(pbProgressBar);
		setSize(200, 150);
	}

	private void configComponents() {
		tfArquivo = new JTextField(15);
		tfArquivo.setEditable(false);
		btImportar = new JButton("Selecionar arquivo");
		btAnalisar = new JButton("Analisar Arquivo");
		btAnalisar.setEnabled(false);
		pbProgressBar = new JProgressBar(0, 100);
		pbProgressBar.setValue(0);
	}
	
	public void expandir(){
		if(taAnalise == null){
			taAnalise = new JTextArea(26,30);
			taAnalise.setLineWrap(true);
			JScrollPane jScrollPane = new JScrollPane(taAnalise);
			jScrollPane.setVerticalScrollBar(new JScrollBar(JScrollBar.VERTICAL));
			add(jScrollPane);
			setSize(400, 520);
		}
	}

	public void setListener(ActionListener actionListener, InternalFrameListener internalFrameListener){
		btImportar.addActionListener(actionListener);
		btAnalisar.addActionListener(actionListener);
		this.addInternalFrameListener(internalFrameListener);
	}

}
